software master at the intersection of technology, science and art

home

download

expression trees


Expression trees represent code in a tree-like data structure, where each node is an expression, for example, a method call or a binary operation such as x < y. Expression trees enable dynamic modification of executable code, teh execution of Linq queries in various databases, and the creation of dynamic queries. This topic is extensive and expression trees may be created via the API or from Lambda Expressions(single-line lambdas only). The important issues are that we are again dealin gwith delegates. that the compiler emits code to build the expression tree which is parsed and compiled at runtime - a form of late binding. Also Expression Trees are not Lambda Expressions which is well illistrated by Marlon Grech


An Expression tree is a tree where each node represents an action on its leaves. As in the sample below. Generating Dynamic Methods is well discussed by Alexandra Russina.